<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Gerenciamento Escola - Disciplinas</title>

<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/validacao.js" /></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript">
	function openConteudo(idConteudo, idNome) {
		nome = '</br></br><b>Conteudo de ' + document.getElementById(idNome).value + '</b></br></br>';
		conteudo = document.getElementById(idConteudo).value;
		novaDiva = '<div id="conteudoSolicitado" align="center" >'+ nome + conteudo + '</div>';
		document.getElementById('conteudoResize').innerHTML = novaDiva;
		document.getElementById('conteudoResize').style.display = 'block';
	}
	function closeConteudo() {
		document.getElementById('conteudoResize').innerHTML = '';
		document.getElementById('conteudoResize').style.display = 'none';
	}

	
</script>
</head>
<body>
<div class="divLogout"><a href="logoutServlet"><c:out value="Logout(${sessionUser.login})"></c:out></a></div>


<div class="tablegrid">

		
		<table class="tableListUser" >
			<tr height="28px">
				<td class="celListCenter"> <a href="pages/professores.jsf">Professores</a></td>
				<td class="celListCenter"> <a href="pages/alunos.jsf">Alunos</a></td>
				<td class="celListCenter"> <a href="listarDisciplinas">Disciplinas</a></td>
				<td class="celListCenter"> <a href="pages/usuarios.jsf">Usuários</a></td>
			</tr>
			<tr height="28px">
				<td colspan="4" align="center">Gerenciamento de Disciplinas</td>
			</tr>
			<tr>
            	<td align="center"  colspan="2">
                    <a ><img class="icone" src="img/icon/disc_search.png"/></a>
                </td>
                <td align="center"  colspan="2" >
                    <a href="disciplina"><img class="icone" src="img/icon/disc_add.png"/></a>
                </td>
            </tr>
            <tr>
            	<td align="center"  colspan="2">
                    <a>Listar Disciplinas</a>
                </td>
                <td align="center"  colspan="2" >
                    <a href="disciplina">Adicionar Disciplina</a>
                </td>
            </tr>
		</table>			
		<div class="formHeader">Disciplinas Cadastradas</div>
		<c:if test="${not empty param.msg}">
			<div class="erroMsg">
				<c:choose>
					<c:when test="${param.msg eq 'salvo' }">
						Disciplina salva com sucesso
						
					</c:when>
					<c:when test="${param.msg eq 'removido'}">
						Disciplina removida com sucesso
					</c:when>
					<c:when test="${param.msg eq 'erro_remover'}">
						Ocorreu um erro ao remover a disciplina
					</c:when>
					<c:when test="${param.msg eq 'erro_salvar'}">
						Ocorreu um erro ao salvar a disciplina
					</c:when>
				</c:choose>
			</div>
		</c:if>
		
		<table class="tableListUser">
			<tr class="gridHeader">
				<td>Id</td>
				<td>Nome</td>
				<td>Carga Horária</td>
				<td>Professor</td>
				<td>Conteudo</td>
				<td>Excluir/Editar</td>
			</tr>
			<c:forEach items="${disciplinas}" var="disciplina">
				<tr>
					<td class="celListLeft"><c:out value="${disciplina.id}" /></td>
					<td class="celListLeft"><c:out value="${disciplina.nome}" />
						<input type="hidden" id="nomePorId${disciplina.id}" value="${disciplina.nome}">
					</td>
					<td class="celListCenter"><c:out value="${disciplina.cargaHoraria}" /></td>
					<td class="celListLeft"><c:out value="${disciplina.professor.nome}" /></td>
					<td class="celListCenter">
						<input type="hidden" id="conteudoPorId${disciplina.id}" value="${disciplina.conteudo}">
						
					<a onclick="openConteudo('conteudoPorId${disciplina.id}', 'nomePorId${disciplina.id}')">
					Mostrar...
					</a>
					</td>
					<td class="celListCenter">
						<a href="disciplina?acao=remover&id=${disciplina.id}" 
						onclick="return confirm('Deseja excluir o disciplina?');">
						<img title="EXCLUIR" class="iconeListUser" src="img/icon/disc_delete.png"></a> 
						<a href="disciplina?acao=editar&id=${disciplina.id}">
						<img title="EDITAR" class="iconeListUser" src="img/icon/disc_edit.png"></a></td>
				</tr>
			</c:forEach>
		</table>
	</div>
	<div id="conteudoResize" onclick="closeConteudo()">
		</div>


</body>
</html>